package com.zige.zige.activity;

import com.zige.zige.LittleZebraApplication;
import com.zige.zige.R;
import com.zige.zige.dialog.LoadingDialog;
import com.zige.zige.service.NetworkStateService;
import com.zige.zige.utils.NetworkUtils;

import android.app.ActionBar;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.FragmentActivity;
import android.view.Gravity;
import android.view.View;
import android.view.WindowManager;
import android.widget.ImageButton;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

public class BaseActivity extends FragmentActivity {
	protected BaseActivity mContext;
    public LittleZebraApplication  application;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏2222222222
        super.onCreate(savedInstanceState);
        mContext = this;
        application = (LittleZebraApplication)LittleZebraApplication.getInstance();


//        if(!NetworkUtils.isNetworkAvailable(mContext)){
//            startService(new Intent(mContext, NetworkStateService.class));
//        }
    }

    private LoadingDialog dialog;

    public void showLoadingDialog() {
        if (dialog == null) {
            dialog = new LoadingDialog(this, R.style.theme_dialog_loading);
        }
        dialog.show();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
    }





    public void closeLoadingDialog() {
        if (dialog != null) {
            dialog.dismiss();
        }

    }

    protected void onResume() {
        super.onResume();
    }

    protected void onPause() {
        super.onPause();
    }




    protected <T extends View> T serchViewById(int id){
        return (T)findViewById(id);
    }
    
    protected <T extends View> T findViewByIds(int res) {
        View view = findViewById(res);

        return (T) view;
    }

    public void showErrorDialog(String message){
        Bundle bundle = new Bundle();
        Intent intent =new Intent();
        intent.setClass(this, ErrorMsgActivity.class);
        bundle.putString("message",message);
        intent.putExtras(bundle);
        startActivity(intent);
        overridePendingTransition(R.anim.error_msg_in, 0);
    }


}
